Watchdog driver for the XMC microcontroller family.
More...
Watchdog driver for the XMC microcontroller family.
The watchdog unit (WDT) improves the system integrity, by triggering the system reset request to bring the system back from the unresponsive state to normal operation.
This LLD provides the Configuration structure XMC_WDT_CONFIG_t and initialization function XMC_WDT_Init().
It can be used to:
- Start or Stop the watchdog timer. (XMC_WDT_Start() and XMC_WDT_Stop())
- Service the watchdog timer. (XMC_WDT_Service())
- Configure the service window upper bound and lower bound timing values. (XMC_WDT_SetWindowBounds())
- Enable the generation of the pre-warning event for the first overflow of the timer. (XMC_WDT_SetMode())
- Clear the pre-warning alarm event. It is mandatory to clear the flag during pre-warning alarm ISR, to stop generating reset request for the second overflow of the timer. (XMC_WDT_ClearAlarm())
- Suspend the watchdog timer during Debug HALT mode. (XMC_WDT_SetDebugMode())
- Configure service indication pulse width.(XMC_WDT_SetServicePulseWidth())
◆ XMC_WDT_MAGIC_WORD
| #define XMC_WDT_MAGIC_WORD |
◆ XMC_WDT_CONFIG_t
Structure for initializing watchdog timer. Use type XMC_WDT_CONFIG_t for this structure.
◆ XMC_WDT_DEBUG_MODE_t
Defines debug behaviour of watchdog when the CPU enters HALT mode. Use type XMC_WDT_DEBUG_MODE_t for this enum.
◆ XMC_WDT_MODE_t
Defines working modes for watchdog. Use type XMC_WDT_MODE_t for this enum.
◆ XMC_WDT_DEBUG_MODE
Defines debug behaviour of watchdog when the CPU enters HALT mode. Use type XMC_WDT_DEBUG_MODE_t for this enum.
| Enumerator |
|---|
| XMC_WDT_DEBUG_MODE_STOP | Watchdog counter is paused during debug halt.
|
| XMC_WDT_DEBUG_MODE_RUN | Watchdog counter is not paused during debug halt.
|
Definition at line 112 of file xmc_wdt.h.
◆ XMC_WDT_MODE
Defines working modes for watchdog. Use type XMC_WDT_MODE_t for this enum.
| Enumerator |
|---|
| XMC_WDT_MODE_TIMEOUT | Generates reset request as soon as the timer overflow occurs.
|
| XMC_WDT_MODE_PREWARNING | Generates an alarm event for the first overflow. And reset request after subsequent overflow, if not serviced after first overflow.
|
Definition at line 100 of file xmc_wdt.h.
◆ XMC_WDT_ClearAlarm()
- Parameters
-
- Returns
- None
- Description:
- Clears pre-warning alarm by setting ALMC bit in WDTCLR register.
- In pre-warning mode, first overflow of the timer upper window bound fires the pre-warning alarm. XMC_WDT_ClearAlarm() must be invoked to clear the alarm alarm. After clearing of the alarm, watchdog timer must be serviced within valid time window. Otherwise watchdog timer triggers the reset request up on crossing the upper bound value in a subsequent cycle.
- Related APIs:
- XMC_WDT_Service(), XMC_WDT_SetMode()
Definition at line 422 of file xmc_wdt.h.
◆ XMC_WDT_Disable()
| void XMC_WDT_Disable |
( |
void |
| ) |
|
◆ XMC_WDT_Enable()
| void XMC_WDT_Enable |
( |
void |
| ) |
|
◆ XMC_WDT_GetCounter()
- Parameters
-
- Returns
- uint32_t Current count value of watchdog timer register (TIM). Range: [0H to FFFFFFFFH]
- Description:
- Reads current count of timer register (TIM).
- Invoke this API before servicing or feeding the watchdog to check whether count is between lower and upper window bounds.
- Related APIs:
- XMC_WDT_Service()
Definition at line 378 of file xmc_wdt.h.
◆ XMC_WDT_Init()
- Parameters
-
| config | pointer to a constant watchdog configuration data structure. Refer data structure XMC_WDT_CONFIG_t for detail. |
- Returns
- None
- Description:
- Initializes and configures watchdog with configuration data pointed by config.
- It invokes XMC_WDT_Enable() to enable clock and release reset. Then configures the lower and upper window bounds, working mode (timeout/pre-warning), debug behaviour and service request indication pulse width.
- Note:
- With out invoking this XMC_WDT_Init() or XMC_WDT_Enable(), invocation of other APIs like XMC_WDT_SetWindowBounds(), XMC_WDT_SetMode(), XMC_WDT_SetServicePulseWidth(), XMC_WDT_SetDebugMode(), XMC_WDT_Start(), XMC_WDT_GetCounter(), XMC_WDT_Service(), XMC_WDT_ClearAlarm() has no affect.
Definition at line 88 of file xmc_wdt.c.
Referenced by L0_Watchdog_Config().
◆ XMC_WDT_Service()
◆ XMC_WDT_SetDebugMode()
- Parameters
-
| debug_mode | running state of watchdog during debug halt mode. Refer XMC_WDT_DEBUG_MODE_t for valid values. |
- Returns
- None
- Description:
- Sets debug behaviour of watchdog by modifying DSP bit of CTR register.
- Depending upon DSP bit, the watchdog timer stops when CPU is in HALT mode. The debug behaviour is initially set as XMC_WDT_DEBUG_MODE_STOP during initialization in XMC_WDT_Init(). Invoke this API to change the debug behaviour as needed later in the program.
Definition at line 321 of file xmc_wdt.h.
◆ XMC_WDT_SetMode()
- Parameters
-
| mode | is one of the working modes of the watchdog timer, i.e timeout or pre-warning. Refer XMC_WDT_MODE_t for valid values. |
- Returns
- None
- Description:
- Sets watchdog working mode (timeout or pre-warning) by updating PRE bit of CTR register.
- The working mode is set during initialization in XMC_WDT_Init(). Invoke this API to alter the mode as needed later in the program.
Definition at line 286 of file xmc_wdt.h.
◆ XMC_WDT_SetServicePulseWidth()
| __STATIC_INLINE void XMC_WDT_SetServicePulseWidth |
( |
uint8_t |
service_pulse_width | ) |
|
- Parameters
-
| service_pulse_width | specifies Service indication pulse width in terms of fwdt. Range: [0H – FFH]. |
- Returns
- None
- Description:
- Sets service indication pulse width by updating SPW bit field of CTR register.
- The service indication pulse (with width service_pulse_width + 1 in fwdt cycles) is generated on successful servicing or feeding of watchdog. The pulse width is initially set during initialization in XMC_WDT_Init(). Invoke this API to alter the width as needed later in the program.
Definition at line 303 of file xmc_wdt.h.
◆ XMC_WDT_SetWindowBounds()
| __STATIC_INLINE void XMC_WDT_SetWindowBounds |
( |
uint32_t |
lower_bound, |
|
|
uint32_t |
upper_bound |
|
) |
| |
- Parameters
-
| lower_bound | specifies watchdog window lower bound in terms of watchdog clock (fWDT) cycles. Range: [0H to FFFFFFFFH]. |
| upper_bound | specifies watchdog window upper bound in terms of watchdog clock (fWDT) cycles. Range: [0H to FFFFFFFFH]. |
- Returns
- None
- Description:
- Sets watchdog window lower and upper bounds by updating WLB and WUB registers.
- Window lower and upper bounds are set during initialization in XMC_WDT_Init(). Invoke this API to alter the values as needed later in the program. This upper bound and lower bound can be calculated by using the below formula
upper_bound or lower_bound = desired_boundary_time(sec) * fwdt(hz)
- Note:
- Always ensure that upper_bound is greater than the lower_bound value. If not, whenever timer crosses the upper_bound value it triggers the reset(wdt_rst_req) of the controller.
Definition at line 268 of file xmc_wdt.h.
Referenced by Lade_Kennlinien_Parameter_Eeprom().
◆ XMC_WDT_Start()
- Parameters
-
- Returns
- None
- Description:
- Start the watchdog timer by setting ENB bit of CTR register.
- Invoke this API to start the watchdog after initialization, or to resume the watchdog when paused by invoking XMC_WDT_Stop().
- Related APIs:
- XMC_WDT_Init(), XMC_WDT_Stop()
Definition at line 340 of file xmc_wdt.h.
Referenced by main().
◆ XMC_WDT_Stop()
- Parameters
-
- Returns
- None
- Description:
- Pauses watchdog timer by resetting ENB bit of CTR register.
- Invoke this API to pause the watchdog as needed in the program e.g. debugging through software control.
- Related APIs:
- XMC_WDT_Init(), XMC_WDT_Stop()
Definition at line 358 of file xmc_wdt.h.